import 'dart:convert';

import 'package:example_example/pages/view/LoadingView.dart';
import 'package:example_example/services/ScreenAdapter.dart';
import 'package:example_example/services/TLSizeFit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import '../../YColors.dart';
import '../../bean/BaseBean.dart';
import '../../global/Global.dart';
import '../../global/GlobalUrl.dart';
import '../../pages/view/LoadingDialog.dart';
import '../../util/HttpUtil.dart';
import '../../util/LogUtil.dart';
import '../../util/ToastUtils.dart';
import '../../util/Storage.dart';

//import '../view/ItemToDoTaskView.dart';
//import '../view/ItemToDoTaskView2.dart';
import '../../bean/order/AutogeneratedBean.dart';
import '../../pages/person/Login.dart';
import '../../bean/ToTaskBean.dart';
import '../../pages/view/HeaderView.dart';


/**刷新来自官网的demo
 * flutter_easyrefresh   刷新的第三方组件
 * https://pub.dev/packages/flutter_easyrefresh/example
 */

class TodoTaskPage extends StatefulWidget {
  TodoTaskPage({Key key}) : super(key: key);

  _TodoTaskPageState createState() => _TodoTaskPageState();
}

class _TodoTaskPageState extends State<TodoTaskPage> {
  EasyRefreshController _controller;

  // 条目总数
//  int _count = 6; //20

  List dataList = [];
  int pageIndex = 1;
  int count = 1;

  List selectedList = [];

  bool passFlag = false;
  bool noPassFlag = false;
  String inputValue = "";
  int inputLength = 0;

  @override
  void initState() {
    super.initState();

    _controller = EasyRefreshController();

    // 设置EasyRefresh的默认样式
//    EasyRefresh.defaultHeader = ClassicalHeader(
//      enableInfiniteRefresh: false,
//      refreshText: "拉动刷新",
//      refreshReadyText:"释放刷新",
//      refreshingText: "正在刷新...",
//      refreshedText: "刷新完成",
//      refreshFailedText: "刷新失败",
//      noMoreText: "没有更多数据",
//      infoText: "更新于 %T",
//    );

    initHttpData();
  }

  @override
  Widget build(BuildContext context) {
    TLSizeFit.initialize();
    ScreenAdapter.init(context);

    return Scaffold(
//        appBar: AppBar(
//          title: Text("EasyRefresh"),
//        ),
      appBar: HeaderView(
        title: "待办任务",
        isShowReturnArrow: true,
      ),
      body: Stack(
        children: <Widget>[
          EasyRefresh.custom(
            enableControlFinishRefresh: false,
            // 是否开启控制结束刷新
            enableControlFinishLoad: true,
            // 是否开启控制结束加载
            controller: _controller,
            // EasyRefresh控制器
//          header: ClassicalHeader(),
            header: ClassicalHeader(
              enableInfiniteRefresh: false,
              refreshText: "拉动刷新",
              refreshReadyText: "释放刷新",
              refreshingText: "正在刷新...",
              refreshedText: "刷新完成",
              refreshFailedText: "刷新失败",
              noMoreText: "没有更多数据",
              showInfo: false, // 是否显示时间
//            infoText: "更新于 %T",
            ),
//          footer: ClassicalFooter(),
            footer: ClassicalFooter(
              loadText: "拉动加载",
              loadReadyText: "释放加载",
              loadingText: "正在加载...",
              loadedText: "加载完成",
              loadFailedText: "加载失败",
              noMoreText: "没有更多数据",
              infoText: "更新于 %T",
            ),
            onRefresh: () async {
              print('onRefresh');
              pageIndex = 1;
              initHttpData();
//          await Future.delayed(Duration(seconds: 2), () {
//
//          });
            },
            onLoad: () async {
              print('onLoad');
              pageIndex++;
              initHttpData();
//          await Future.delayed(Duration(seconds: 2), () {
//
////            _controller.finishLoad(noMore: _count >= 40);
//          });
            },
            slivers: <Widget>[
              SliverList(
                delegate: SliverChildBuilderDelegate(
                  (context, index) {
                    if (dataList != null && dataList.length > 0) {
                      return InkWell(
                        child:
                            ItemToDoTaskView(context, dataList[index], index),
                        onTap: () {
                          print("待办任务");
//                      Navigator.pushNamed(context, '/webViewUtilPage',  //WebViewExample
//                          arguments: {
//                            Global.WEBVIEW_TAG: Global.HIISTORYTASK,
//                            "id":dataList[index]["id"],
//                            'dataStr':dataList[index],
//                          }).then((value) {
//                        print('webview:$value');
//                      });

//                      Future.delayed(Duration.zero, () {
                          showDialog(
                              context: context,
                              barrierDismissible: true,
                              builder: (_) {
                                return new LoadingDialog(text: "努力加载中");
                              });
//                      });
//                      new Future.delayed(Duration(seconds: 4), () {
//                        Navigator.of(context).pop();
//                      });

                          setToDoNet(index);
                        },
                      );
                    } else {
                      return Container(
                        width: 60.0,
                        height: 60.0,
                        child: Center(
                          child: Text(''),
                        ),
                        color: index % 2 == 0
                            ? Colors.grey[300]
                            : Colors.transparent,
                      );
                    }

//                return Container(
//                  width: 60.0,
//                  height: 60.0,
//                  child: Center(
//                    child: Text('$index'),
//                  ),
//                  color: index % 2 == 0 ? Colors.grey[300] : Colors.transparent,
//                );

//
                  },
                  childCount: dataList.length,
                ),
              ),
            ],
          ),

          InkWell(
            child: Container(
              width: TLSizeFit.screenWidth,
              height: 30,
              color: YColors.t,
              padding: EdgeInsets.fromLTRB(20, 5, 0, 5),
              child: Text("批量审批"),
            ),
            onTap: () {
              print("去批量审批了");
              
              if(this.selectedList.length<=0){
                ToastUtils.toast("请选择至少一条数据");
                
              }else{
                applyDialog();
              }
            },
          ),

          this.dataList.length <=0 ?LoadingView():Container(),
        ],
      ),

//        persistentFooterButtons: <Widget>[
//          FlatButton(
//              onPressed: () {
//                _controller.callRefresh();
//              },
//              child: Text("Refresh", style: TextStyle(color: Colors.black))),
//          FlatButton(
//              onPressed: () {
//                _controller.callLoad();
//              },
//              child: Text("Load more", style: TextStyle(color: Colors.black))),
//        ]
    );
  }

  initHttpData() async {
//   GET http://10.66.1.100:8181/api/us-process/task/pageUnfinishedForCurrentUser?current=1&size=10
    String apiUrlhttp = GlobalUrl.PROCESSTASK;

    var map = {
      "current": pageIndex,
      "size": "10",
    };

    String access_token = await Storage.getToken();
    LogUtil.init(title: "来自LogUtil", isDebug: false, limitLength: 800);
//    LogUtil.v("获取的access_token：$access_token");
    LogUtil.v("access_token.length：${access_token.length}");
//    Global.ACCESS_TOKEN_VALUE =  access_token.substring(7, access_token.length);  // 7
//    Global.ACCESS_TOKEN_VALUE =  "111222333";  // 7

    var mapHeaders = {
      Global.AUTHORIZATION: access_token,
      Global.CONTENT_TYPE: Global.APPLICATION_JSON
    };

    HttpUtil.get(apiUrlhttp, data: map, headers: mapHeaders, success: (data) {
//      var str = json.encode(data);
//      LogUtil.v("获取的待办任务str：$str");

//      data = json.encode(data);  // Map 转换成 Json 字符串
//      data = json.decode(data);

      // 下拉刷新停止
      _controller.resetLoadState();

      //  上拉加载停止
      _controller.finishLoadCallBack();
//            _controller.finishLoad(noMore: false);
      _controller.finishLoad();

//      LogUtil.v("data:$data");
      var success = data["success"];
//      LogUtil.v("success:$success");
      var message = data["msg"];
      var body = data["data"];
      var code = data["code"];
//      LogUtil.v("body:$body");
      if (success != null && success == true) {
        LogUtil.v("进来了");
        List getList = body["records"];
//        LogUtil.v("getList:$getList");
        LogUtil.v(getList.length);

        if (pageIndex == 1) {
          dataList.clear();
          dataList.addAll(getList);
        } else {
          dataList.addAll(getList);
        }
        print(dataList.length);

        for (var i = 0; i < dataList.length; i++) {
          var name = dataList[i]["name"];
          LogUtil.v("name:$name");
//          var variableJson = getList[i]['variableJson'];
//          LogUtil.v("variableJson:$variableJson");
//          variableJson = json.decode(variableJson);
//          var biProjectName = variableJson["biProjectName"];
//          LogUtil.v("biProjectName:$biProjectName");
          dataList[i]["selectFlag"] = false; // 赋值

//          var variableBean = AutogeneratedBean.fromJson(variableJson);
//          LogUtil.v("variableBean:$variableBean");
//          var biProjectName = variableBean.biProjectName;
//          LogUtil.v("biProjectName:$biProjectName");
        }
        setState(() {
          dataList = dataList;
        });
      } else {
        if (message != null) {
          ToastUtils.toast(message);
        }
        if (code == "401") {
          //用户登录超时
          print("超时了啊");
          Storage.clear(); // 清除数据
          //跳转并关闭当前页面
          Navigator.pushAndRemoveUntil(
            context,
            new MaterialPageRoute(builder: (context) => new LoginPage()),
            (route) => route == null,
          );
        }
      }

//      var jsonMap = BaseBean.fromJson(data);
//      String result = jsonMap.result;
//      String message = jsonMap.message;
//
//      if (result != null && result == "success") {
//
//      } else {
//        if (message != null) {
//          ToastUtils.toast(message);
//        }
//      }
    }, error: (errorMsg) {
      print("待办任务.去做...errorMsg: $errorMsg");
      // 下拉刷新停止
      _controller.resetLoadState();

      //  上拉加载停止
      _controller.finishLoadCallBack();
//            _controller.finishLoad(noMore: false);
      _controller.finishLoad();
    });
  }

  /**
   * 处理待办任务前先访问接口
   */
  setToDoNet(int index) async {
    //

    String taskDefinitionKey = dataList[index]["taskDefinitionKey"];
    var itemBean = dataList[index];
    if (taskDefinitionKey == null || taskDefinitionKey == "") {
      return;
    }
    String apiUrlhttp = GlobalUrl.UPUSERTASKCONFIG;

    var map = {
      "code": taskDefinitionKey,
    };

    String access_token = await Storage.getToken();
    LogUtil.init(title: "来自LogUtil", isDebug: false, limitLength: 800);
//    LogUtil.v("获取的access_token：$access_token");

    var mapHeaders = {
      Global.AUTHORIZATION: access_token,
      Global.CONTENT_TYPE: Global.APPLICATION_JSON
    };

    HttpUtil.get(apiUrlhttp, data: map, headers: mapHeaders, success: (data) {
      Navigator.of(context).pop();

//      接口的数据：{code: 200, success: true, data: {
//      id: 1400018369129914369,
//      utcTitle: 售前立项一级审核,
//      utcType: 1,
//      utcRoutePath: project/prepare/approve,
//      utcFormType: 1,
//      utcFormId: null,
//      utcInterfaceUrl: /us-
//      process/task/auditOne},
//      msg: 操作成功}

      String str = json.encode(data);
      LogUtil.v("接口的数据22:$str");

      var toTaskBean = ToTaskBean.fromJson(data);

      var success = toTaskBean.success;
      if (success != null && success) {
        print("...是否进来了呀");

        var taskBean = toTaskBean.data;
//
        String utcFormId = taskBean.utcFormId;
        String utcFormType = taskBean.utcFormType;
        String utcInterfaceUrl = taskBean.utcInterfaceUrl;
        String utcRoutePath = taskBean.utcRoutePath;
        String utcTitle = taskBean.utcTitle;
        String utcType = taskBean.utcType;

        if (utcFormId == null) {
          utcFormId = "";
        }
        if (utcFormType == null) {
          utcFormType = "";
        }
        if (utcInterfaceUrl == null) {
          utcInterfaceUrl = "";
        }
        if (utcRoutePath == null) {
          utcRoutePath = "";
        }
        if (utcTitle == null) {
          utcTitle = "";
        }
        if (utcType == null) {
          utcType = "";
        }

        utcTitle = Uri.encodeComponent(utcTitle);

        print("utcFormId:$utcFormId");
        print("utcFormType:$utcFormType");

        // 注意拼接的参数不能有null，否则会报错
//        String url = GlobalUrl.WEB_TODOTASK_URL + "?utcFormType="+utcFormType;

//        print("...拼接的url:"+url);
        String variableJsonStr = json.encode(itemBean["variableJson"]);

        String url = "";
        if (utcFormType == "1") {
          url = GlobalUrl.WEB_STATIC_URL;
        } else if(utcFormType == "2"){
          url = GlobalUrl.WEB_DYNAMIC_URL;
        } else {
          url = GlobalUrl.WEB_CUSTOM_URL;
        }

//        var pathURL ="?utcFormId="+utcFormId+"&utcFormType="+utcFormType+"&platform=app"+"&utcInterfaceUrl="+utcInterfaceUrl
//            +"&utcRoutePath="+utcRoutePath+"&utcTitle="+utcTitle+"&utcType="+utcType+"&name="+utcTitle+"&id="+itemBean["id"]+
//            "&taskDefinitionKey="+taskDefinitionKey+"&processInstanceId="
//            +itemBean["processInstanceId"];

        url = url +
            "?utcFormId=" +
            utcFormId +
            "&utcFormType=" +
            utcFormType +
            "&platform=app" +
            "&utcInterfaceUrl=" +
            utcInterfaceUrl +
            "&utcRoutePath=" +
            utcRoutePath +
            "&utcTitle=" +
            utcTitle +
            "&utcType=" +
            utcType +
            "&name=" +
            utcTitle +
            "&id=" +
            itemBean["id"] +
            "&taskDefinitionKey=" +
            taskDefinitionKey +
            "&processInstanceId=" +
            itemBean["processInstanceId"];

//        url = url+"?"+Uri.encodeComponent(pathUrl);

//       url = url + json.encode(pathURL);
//          url = json.encode(url+pathURL);
//           +"&variableJson="+variableJsonStr;

        Navigator.pushNamed(context, '/webViewUtilPage', //WebViewExample
            arguments: {
              Global.WEBVIEW_TAG: Global.HIISTORYTASK,
              Global.WEBVIEW_URL: url,

              "id": dataList[index]["id"],
//                            "count":count++,
              'variableJsonStr': variableJsonStr,
            }).then((value) {
          print('webview:$value');
        });
      } else {}
    }, error: (errorMsg) {
      print("//....error了啊");
      Navigator.of(context).pop();
    });
  }

  /**
   * 审核的弹出框
   */

  applyDialog() {
    print("applyDialog....noPassFlag:$noPassFlag");
    showDialog(
        barrierDismissible: false,
        context: context,
        builder: (context) {
          return StatefulBuilder(
              builder: (BuildContext context, setBottomState) {
            return GestureDetector(
              // 解决点击消失的问题；
              onTap: () {
                return false;
              },
              child: SimpleDialog(
                title: Text("审批"),
                children: <Widget>[
                  SimpleDialogOption(
                    child: Row(
                      children: <Widget>[
                        Image.asset(
                          passFlag
                              ? "images/skill_select.png"
                              : "images/skill_unselect.png",
                          width: 20,
                          height: 20,
                        ),
                        SizedBox(
                          width: 5,
                        ),
                        Text("审批通过"),
                      ],
                    ),
                    onPressed: () {
                      print("你选择了第一个$passFlag");
                      toChange(setBottomState, "pass");
                    },
                  ),

                  SimpleDialogOption(
                    child: Row(
                      children: <Widget>[
                        Image.asset(
                          noPassFlag
                              ? "images/skill_select.png"
                              : "images/skill_unselect.png",
                          width: 20,
                          height: 20,
                        ),
                        SizedBox(
                          width: 5,
                        ),
                        Text("审批不通过"),
                      ],
                    ),
                    onPressed: () {
                      print("你选择了审核不通过noPassFlag:$noPassFlag");
                      toChange(setBottomState, "noPass");
                    },
                  ),
                  noPassFlag
                      ? Container(
                          margin:
                              EdgeInsets.fromLTRB(TLSizeFit.setPx(15), 0, 0, 0),
                          child: Text("不通过原因："),
                        )
                      : Container(),

                  noPassFlag
                      ? Container(
                          padding: EdgeInsets.fromLTRB(
                              TLSizeFit.setPx(10), 0, TLSizeFit.setPx(10), 0),
                          margin: EdgeInsets.fromLTRB(TLSizeFit.setPx(10),
                              TLSizeFit.setPx(10), TLSizeFit.setPx(10), 0),

//                    width: TLSizeFit.setPx(200),
                          height: TLSizeFit.setPx(120),
                          decoration: BoxDecoration(
                            color: Colors.white, // 背景色 zj
                            border: Border.all(
                                // 边框 zj
                                color: Colors.black12, // 边框颜色 zj
                                width: 1.0 // 边框宽度 zj

                                ),
                            borderRadius: BorderRadius.all(// 圆角
                                //  Radius.circular(150),    //圆形
                                Radius.circular(4) // 圆角 zj
                                ),
                          ),
                          child: TextField(
//              controller: _controller_input,
                            autofocus: true,
                            controller: TextEditingController.fromValue(
                                TextEditingValue(
                                    // 设置内容
                                    text: inputValue,
                                    // 保持光标在最后
                                    selection: TextSelection.fromPosition(
                                        TextPosition(
                                            affinity: TextAffinity.downstream,
                                            offset: inputValue.length)))),
                            style: TextStyle(
                                color: Colors.black87,
                                fontSize: ScreenAdapter.size(28)),
//          controller: _controller,
                            maxLength: 800,
                            maxLines: 100,
                            decoration: InputDecoration(
                              hintText: "请详细介绍下您的技术能力，这将会在客户查看您资料时显示。限300字",
                              hintStyle: TextStyle(
                                  fontSize: ScreenAdapter.size(28),
                                  color: YColors.textColorHint),
                              border: InputBorder.none, // 去掉下滑线
                              counterText: '', // 去除输入框底部的字符计数
                            ),
                            onChanged: (value) {
                              inputValue = value;
                              inputLength = value.length;
                              if (inputLength == null) {
                                inputLength = 0;
                              }
                              setState(() {
                                inputLength = inputLength;
                              });
                            },
                          ),
                        )
                      : Container(),

//                  SimpleDialogOption(
//                    child: Text("选择三C"),
//                    onPressed: () {
//                      print("你选择了第三个");
////                  Navigator.pop(context, "C");
//                    },
//                  ),

                  Row(
                    children: <Widget>[
                      FlatButton(
                          child: Text("取消"),
                          onPressed: () {
                            print("取消");
                            Navigator.pop(context); // 关闭
                          }),
                      FlatButton(
                          child: Text("确定"),
                          onPressed: () {
                            print("确定");
//                            Navigator.pop(context, "sure"); // 关闭
                            applyHttp();
                          })
                    ],
                  ),
                ],
              ),
            );
          });
        });
  }

  /**
   * 动态改变dialog 的数据
   */
  toChange(setBottomState, flag) {
    setBottomState(() {
      if (flag == "pass") {
        this.passFlag = !passFlag;
        this.noPassFlag = !passFlag;
      } else {
        this.noPassFlag = !noPassFlag;
        this.passFlag = !noPassFlag;
      }
    });
  }

  /**
   * 审核的接口访问
   */
  applyHttp() async {
    String url = GlobalUrl.TASK_AUDITBATCH;

//    var map = {
//      "current": pageIndex,
//      "size": "10",
//    };

    if (!passFlag && !noPassFlag) {
      ToastUtils.toast("请选择审批状态");
      return;
    }
    String approvalStatus = "";
    if (passFlag) {
      // 审批通过
      approvalStatus = "1";
    }

    if (noPassFlag) {
      // 审批不通过
      approvalStatus = "2";
      if(this.inputValue.length<=0){
        ToastUtils.toast("请输入审批不通过原因");
        return;
      }
    }

//    String strBody = json.encode(this.selectedList); // Map 转换成 Json 字符串
    var map = {
      "approvalStatus": approvalStatus, // 审批通过
      "approvalRemark": this.inputValue,  // 不通过原因
      "taskList": this.selectedList,
    };

    String access_token = await Storage.getToken();
    LogUtil.init(title: "来自LogUtil", isDebug: false, limitLength: 800);
//    LogUtil.v("获取的access_token：$access_token");
//    Global.ACCESS_TOKEN_VALUE =  access_token.substring(7, access_token.length);  // 7

    var mapHeaders = {
      Global.AUTHORIZATION: access_token,
      Global.CONTENT_TYPE: Global.APPLICATION_JSON
    };

    HttpUtil.post(url, data: map, headers: mapHeaders, success: (data) {
      print("审批通过的数据data:$data");
//      审批通过的数据data:{code: 400, success: false, data: null, msg: 提交的审批任务中包含需要录入信息的任务}
//          {"code":"200","success":true,"data":null,"msg":"操作成功"}
      var toTaskBean = ToTaskBean.fromJson(data);
      var msg = toTaskBean.msg;
      if(toTaskBean.success){
        Navigator.pop(context);
        initHttpData();
      }
      ToastUtils.toast(msg);

    }, error: (errorMsg) {
      print("审批报错errorMsg:$errorMsg");
    });
  }

  /**
   * 显示的每一个条目
   */
  Widget ItemToDoTaskView(context, bean, position) {
    // TODO: implement build
    return Container(
      width: double.infinity,
      margin: EdgeInsets.fromLTRB(20, 25, 20, 0),
      padding: EdgeInsets.fromLTRB(0, 0, 10, 20),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Container(
            height: 60,
//            color: YColors.l,
            padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
            child: InkWell(
              child: Image.asset(
                bean["selectFlag"]
                    ? "images/skill_select.png"
                    : "images/skill_unselect.png",
                width: 20,
                height: 20,
              ),
              onTap: () {
                print("选择了我了position:$position");
                setState(() {
                  bean["selectFlag"] = !bean["selectFlag"];

                  if (bean["selectFlag"]) {
                    var seleBean = {};
                    seleBean["id"] = bean["id"];
                    seleBean["taskDefinitionKey"] = bean["taskDefinitionKey"];
                    selectedList.add(seleBean);
                  } else {
                    print("选择了：${bean["id"]}");
                    for (var i = 0; i < selectedList.length; i++) {
                      print("集合里的数据：${selectedList[i]["id"]}");
                      if (selectedList[i]["id"] == bean["id"]) {
                        print("是否删除了啊");
                        selectedList.remove(selectedList[i]);
                        break;
                      }
                    }
                  }

                  for (var i = 0; i < selectedList.length; i++) {
                    var id = selectedList[i]["id"];
                    print("都选择了id:$id");
                  }
                });
              },
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              SizedBox(
                height: 10,
              ),
              Row(
                children: <Widget>[
                  Text(
//              bean["name"] != null ? bean["name"] : "",
                    bean["processDefinitionName"] != null
                        ? bean["processDefinitionName"]
                        : "",
                    style: TextStyle(
                      fontSize: 18.0,
                      color: YColors.a,
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 14,
              ),

              Row(
                children: <Widget>[
                  Text(
                    "业务名称",
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                  SizedBox(
                    width: 30,
                  ),
                  Text(
                    getBusinessName(bean),
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 10,
              ),

              Row(
                children: <Widget>[
                  Text(
                    "开始时间",
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                  SizedBox(
                    width: 30,
                  ),
                  Text(
                    bean["createTime"] != null ? bean["createTime"] : "",
//              getDataStatusText(bean),
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                ],
              ),

              SizedBox(
                height: 10,
              ),

              Row(
                children: <Widget>[
                  Text(
                    "状态",
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                  SizedBox(
                    width: 60,
                  ),
                  Text(
//              "状态。。。。。",
//              bean["status"]!=null? bean["status"]:"",
                    getDataStatusText(bean),
                    style: TextStyle(
                      fontSize: 14.0,
                      color: YColors.c,
                    ),
                  ),
                ],
              ),

              SizedBox(
                height: 10,
              ),
//        InkWell(
//          child: Container(
//            padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
//            width: double.infinity,
////            color: YColors.l,
//            child: Row(
//              children: <Widget>[
//                Container(
//                  padding: EdgeInsets.fromLTRB(7, 4, 7, 4),
////                  color: YColors.m,
//                  child: Text(
//                    "查看流程图",
//                    style: TextStyle(
//                      fontSize: 14.0,
//                      color: YColors.a,
//                    ),
//                  ),
//
//                  decoration: BoxDecoration(
//                    color: YColors.m,
//                    borderRadius: BorderRadius.all(new Radius.circular(4)),
//                  ),
//                ),
//              ],
//            ),
//          ),
//          onTap: () {
//            print("查看流程图");
//            String processInstanceId = bean["processInstanceId"];
//            print("查看流程图processInstanceId:$processInstanceId");
//            if (processInstanceId == null) {
//              processInstanceId = "";
//            }
//            String url = GlobalUrl.WEB_CHART_URL +
//                "?processInstanceId=" +
//                processInstanceId +
//                "&platform=app";
//            Navigator.pushNamed(context, '/webViewUtilPage', //WebViewExample
//                arguments: {
//                  Global.WEBVIEW_TAG: Global.HIISTORYTASK,
//                  Global.WEBVIEW_URL: url,
//                }).then((value) {
//              print('webview:$value');
//            });
//          },
//        ),
            ],
          ),
        ],
      ),
      decoration: BoxDecoration(
          // 边框 zj
          color: YColors.t, // 背景色 zj
//        border: Border.all(
//          // 边框 zj
//            color: Colors.black12, // 边框颜色 zj
//            width: 1.0 // 边框宽度 zj
//
//        ),
          borderRadius: BorderRadius.all(// 圆角
              //  Radius.circular(150),    //圆形
              Radius.circular(4) // 圆角 zj
              ),
          boxShadow: [
            BoxShadow(
//                            color: Colors.black12,
//              color: Color(0x554CBC5A), // 55  是透明度
                color: Color(0x12000000), // 55  是透明度
                offset: Offset(0.0, 2.0), //阴影xy轴偏移量
                blurRadius: 4.0, //阴影模糊程度
                spreadRadius: 1 //阴影扩散程度
                )
          ]

//            // 设置单圆角：左上角的圆角为5，右上角的圆角为10
//            borderRadius: BorderRadius.only(
//                    topLeft: Radius.circular(5),
//                   topRight: Radius.circular(10),
//              ),

          ),
    );
  }

  /**
   * 获取业务名称ame
   */
  String getBusinessName(bean) {
    var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
    variableJson = json.decode(variableJson);
    var ppProjectName = variableJson["title"]; //ppProjectName
//    LogUtil.v("ppProjectName:$ppProjectName");
    if (ppProjectName == null) {
      ppProjectName = "";
    }
    return ppProjectName;
  }

  /**
   * 状态
   */
  String getDataStatusText(bean) {
    var variableJson = bean['variableJson'];
//  LogUtil.v("variableJson:$variableJson");
    variableJson = json.decode(variableJson);
    var statusText = variableJson["statusText"]; //statusText
//  LogUtil.v("statusText:$statusText");
    if (statusText == null) {
      statusText = "";
    }
    return statusText;
  }
}
